home *** CD-ROM | disk | FTP | other *** search
Wrap
/*Online dictionary and thesauris Vers 2.1 This script uses the Meriam Webster site . www.m-w.com */ if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then exit(20) nl='a'x delaybub=0 call setdefaults() call buildgui() do while ~eof(ca) if delaybub>0 then do delaybub=delaybub-1 if delaybub=0 then do bubleon=newbub call topipe('bubble top 'bubx 'left 'buby 'gt "'help.newbub'"') end end call topipe('tick 50') in= readln(ca) parse var in in1 in2 in3 in4 in5 . if (in1='help' & helpon~=0 ) then do call bubble(in2) end if in1='active' then call bubble(0) if in1='key' then call key() if in1='gadget' then call gadget() if in1='iconify' then call iconify() if in1='menu' then call menu() if in1='close' then call windowclosed() end exit key: scrpos=topipe('id 'txtgad) if scrpos=oldpos then scrpos=scrpos-40 if ((in2=77) & (scrpos<oldpos)) then scrpos=topipe('id 'txtgad' scroll' scrpos+80) if (in2=76) then do if (scrpos>79) then scrpos=topipe('id 'txtgad' scroll' scrpos-80) else scrpos=topipe('id 'txtgad' scroll 0' ) end return gadget: call bubble(0) if in2=wordgad then do parse var in . . w . call topipe('id 'lay1' dis 1 ref') call topipe('id 'lay2' dis 1 ref') if level>0 then call topipe('id 'abortgad' dis 0 ref') call trans() call writeln(ca,'id 'txtgad' scroll -1 bd gt "'length(savetx)+1'"') newpos=topipe(savetx) call topipe('id 'txtgad' scroll 'oldpos) call topipe('id 'lay1' dis 0 ref') call topipe('id 'lay2' dis 0 ref') call topipe('id 'abortgad' s 0 dis 1 ref') oldpos=newpos end if in2=quitgad then exit if in2=levelgad then level=in3 if in2=bookgad then book=in3 if in2=cleargad then oldpos=topipe('id 'txtgad' gt ""') if in2=savegad then do call writeln(ca,'id 'filegad' s 1 save 1 fn "'filename'"') parse value readln(ca) with res1 '"' res2 '"' if (res1>0) then do filename=res2 call writeln(ca,'id 'txtgad' read') len=readln(ca) data=readch(ca,len) if( open(out,res2,'W')) then do call writech(out,data) call close(out) end end end return windowclosed: exit return setdefaults: parse source . . called . oldpos=0 level=0 book=0 filename='' scrpos='' prono='' theno='' envname='onlinedictionary' call getenv() abouttx='Online Dictionary & Thesaurus*nVers 1.1*nAuthor William Parker*nGUI by AWNPipe:' return buildgui: call open(ca,"awnpipe:dict/xc") call topipe(' it "Dict Thesa" "Online Dictionary & Thesaurus" sk v defg ig h state m a 'window' ii "'called'"' ) lay1=topipe(' layout weih 0') call topipe(' label gt "Word: " ua') wordgad=topipe('string chl lj') help.wordgad=' Enter word to look up ' levelgad=topipe('chooser cl "First|Major|All" pu weiw 0') help.levelgad='Select look up depth*n First Entry*n Major Entries*n All Entries' bookgad=topipe('chooser cl "Dictionary|Thesaurus" pu weiw 0') help.Bookgad='Select book to search in*n Dictionary definition*n Thesaurus information' call topipe(' le') txtgad=topipe('textfield ro arrows') help.txtgad=' This area displays the retreived definitions. It is read only *n but you may drag and copy the results to the clipboard. *n The cursor keys can be used to scroll the information.' lay2=topipe(' layout weih 0') abortgad=topipe('button pb gt "Abort" dis 1') help.abortgad=' Abort multiple retreival*navailable for major and all*noptions' savegad=topipe('button gt "Save Log"') help.savegad=' Save retreived definitions to a file ' cleargad=topipe('button gt "Clear Log"') help.cleargad=' Remove all retreived definitions ' quitgad=topipe('button gt "Quit"') help.quitgad=' Quit the dictionary ' call topipe(' layoutend') filegad=topipe('getfile save ua') men0gad= topipe('Menu gt "Project|Window|$@SSnapshot|$@UUnsnapshot|@AAbout|@H^&Bubble Help|-|@QQuit"') call pragma('W','N') if (showlist('A','MIAMI')|(showlist('P','MIAMI.1'))) then do men1gad= topipe('Menu gt "Miami|Online|Offline|Status|Hide GUI|Show GUI|SSL Version 2|$On|$Off|-|Quit Miami"') miamifound=1 end call pragma('W') call topipe("open") return topipe: /* this routine does error checking on lines written to pipe.*/ /*get line to output*/ parse arg out /* write to the pipe*/ call writeln(ca,out) /*get responce and parse it.*/ res=readln(ca) parse var res res1 res2 res3 /* if all is ok return the second part of the responce (usualy the GID)*/ if res1='ok' then return(res2) /* something went wrong, we notify the user then exit */ /*show problem line and responce (reponce may be just a blank line)*/ say 'error from: 'out say ' responce: ' in exit trans: if testtcp() then return savetx='0a'x||'---------------'||'0a'x newword=w call topipe('id 0 s 8 gt " Connecting for 'newword'"') savew=w w=urlencode(w) if book=0 then t1='book=Dictionary&va='w else t1='book=Thesaurus&va='w t2=length(t1) t2='Content-Length: 't2 if open(net,'tcp:www.m-w.com/80') then do call topipe('id 0 s 8 gt " Getting information for 'newword'"') call writeln(net,"POST /cgi-bin/dictionary HTTP/1.0") call writeln(net,"User-Agent: MSIE/4.0; (Spoofed by AWNPdictthing (1.0 beta))") call writeln(net,"Accept: */*;q=1") call writeln(net,"Host: www.m-w.com") call writeln(net,t2) call writeln(net,"Content-Type: application/x-www-form-urlencoded") call writeln(net,"") call writeln(net,t1) call writeln(net,"") def='' do while ~eof(net) if length(def)< 54000 then def=def||readch(net,10000) end call close(net) savedef=def call getdef() end else do savetx=savetx||'0a'x||'Connect Failed for 'newword||'0a'x call Showtx(0,"Could not connect to m-w.com") end return(0) getdef: call topipe('id 0 s 8 gt " Parsing result for 'newword'"') if book=0 then parse var def 'Main Entry:' . '0a'x d1 '</form>' else parse var def 'Entry Word:' . '0a'x d1 '</form>' txt=htmltotx(d1) if txt='' then txt= 'not found' if book =0 then savetx=savetx||'0a'x||' (dict) >>>> 'newword' <<<<'||'0a0a'x||txt||'0a'x else savetx=savetx||'0a'x||' (thes) >>>> 'newword' <<<<'||'0a0a'x||txt||'0a'x if savedef~='' then call extradef() call topipe('id 0 s 8 gt " Online Dictionary & Thesaurus"') return showtx: call open(ptx,'awnpipe:kctxt/xc') call writeln(ptx,'db dg "Dictionary & Thesauris info" q cg cm v m a so si ') call writeln(ptx,'label lj gt "'arg(2)'"') if arg(1)=0 then call writeln(ptx,'button gt "O.K." close') call writeln(ptx,'open') if arg(1)~=0 then call writeln(ptx,'tick 'arg(1)) else call writeln(ptx,'m') call close(ptx) return(0) menu: if in2=1 then do if in3=5 then do if in4=0 then do address command "echo yes >ENV:Miami/SSLVERSION2" call showtx(200,' Miami SSL Version 2 on ') end else do address command "echo no >ENV:Miami/SSLVERSION2" call showtx(200,' Miami SSL Version 2 off ') end return() end if ~show('P','MIAMI.1') then do if in3=1 | in3=1 | in3=6 then do call showtx(200,' Miami is not running ') return() end address command 'Run >NIL: Miami:Miami ' do 5 while ~show('P','MIAMI.1') address command 'waitforport MIAMI.1' end if rc=5 then return() end if in3=1 | in3=6 then address MIAMI.1 'OFFLINE' if in3=7 then address MIAMI.1 'QUIT' if in3=0 then address MIAMI.1 'ONLINE' if in3=3 then address MIAMI.1 'HIDE' if in3=4 then address MIAMI.1 'SHOW' if in3=2 | in3=0 | in3=1 then do address MIAMI.1 'ISONLINE' if rc then call showtx(400,' Miami is online ') else call showtx(400,' Miami is offline ') end end if in2=0 then do if in3=0 then do if in4=0 then call setenvarc() if in4=1 then call unsetenvarc() end if in3=1 then call showtx(500,abouttx) if in3=2 then do helpon=in5 if helpon=0 then call bubble(0) end if in3=4 then exit end return() iconify: if in2=1 then call topipe('id 0 s 32') else call topipe('id 0 s 64') call bubble(0) return getenv: if(open(env,'env:'envname,'R')) then do windows=readln(env) filename=readln(env) call close(env) parse var windows wl wt ww wh . window= 'top' wt 'left' wl 'width' ww 'height' wh end else window='tl width 400 height 200' return setenv: call writeln(ca,'id 0 read') windowr=readln(ca) parse var windowr wl wt ww wh . if (datatype(wt,N) &datatype(wl,N) &datatype(ww,N) & datatype(wh,N) ) then do call open(env,'env:'envname,'W') call writeln(env,windowr) call writeln(env,filename) call close(env) end return(0) setenvarc: call setenv() address command 'copy env:'envname' envarc:'envname '>nil:' return unsetenvarc: call setenv() if exists('envarc:'envname) then delete('envarc:'envname) if exists('env:'envname) then delete('env:'envname) return testtcp: if miamifound='1' then do if (showlist('P','MIAMI.1')) then address MIAMI.1 'ISONLINE' else rc=0 if ~rc then do call showtx(0,'Miami is not online*n *nYou must be online to use *n the dictionary or thesauris.*n *nYou can start Mimai from the menus.') savetx='' return(1) end end call pragma('W','N') if ~showlist(H,'TCP') then do if miamifound=1 then call showtx(0,'You must be online to use*n the dictionary or thesauris.*n *nYou can start Mimai from the menus.') else call showtx(0,'Can not find TCP device*n *nYou must be online to use*n the dictionary or thesauris.') savetx='' call pragma('W') return(1) end call pragma('W') return(0) bubble: newbub=arg(1) if newbub=-1 then newbub=0 if (bubbleon=newbub) then return() if bubbleon~=0 then call topipe('bubble') if newbub=0 then delaybub=0 else do bubx=in3 buby=in4 delaybub=3 end return extradef: parse var savedef '<select name=jump size=3>' options '</select' . '<input type=hidden name=list value="' list '"' savedef='' if options='' then return(0) parse var options '>' newword '0a'x options do while options~='' call writeln(ca,'read id 'abortgad) if readln(ca)~=0 then do savetx=savetx||'0a'x||' OPERATION ABORTED !'||'0a'x return(0) end parse var options '>' newword '0a'x options if (level=0 ||(right(newword,1)~=']' & level=1)) then savetx=savetx' * 'newword else call transmore() end return(0) transmore: if testtcp() then return call topipe('id 0 s 8 gt " Connecting for 'newword'"') if book=0 then t1='hdwd='savew'&book=Dictionary&jump='newword'&list='list else t1='hdwd='savew'&book=Thesaurus&jump='newword'&list='list t1=urlencode(t1) t2=length(t1) t2='Content-Length: 't2 if open(net,'tcp:www.m-w.com/80') then do call topipe('id 0 s 8 gt " Getting information for 'newword'"') call writeln(net,"POST /cgi-bin/dictionary HTTP/1.0") call writeln(net,"User-Agent: MSIE/4.0; (Spoofed by AWNPdictthing (1.0 beta))") call writeln(net,"Accept: */*;q=1") call writeln(net,"Host: www.m-w.com") call writeln(net,t2) call writeln(net,"Content-Type: application/x-www-form-urlencoded") call writeln(net,"") call writeln(net,t1) call writeln(net,"") def='' do while ~eof(net) if length(def)< 54000 then def=def||readch(net,10000) end call close(net) call getdef() end else do savetx=savetx||'0a'x||'>>Connect Failed for 'newword'<<'||'0a'x call Showtx(0,"Could not connect to m-w.com") options='' end return(0) urlencode: uin=translate(arg(1),'+',' ') do while index(uin,';')>0 parse var uin in1 ';' in2 uin=in1||'%3B'||in2 end do while index(uin,'=')>0 parse var uin in1 '=' in2 uin=in1||'%3D'||in2 end do while index(uin,'[')>0 parse var uin in1 '[' in2 uin=in1||'%5B'||in2 end do while index(uin,']')>0 parse var uin in1 ']' in2 uin=in1||'%5D'||in2 end do while index(uin,',')>0 parse var uin in1 ',' in2 uin=in1||'%2C'||in2 end return(uin) htmltotx: d1=arg(1) d1=translate(d1,' ','0a0d'x) dt='' do while index(d1,'<br>')>0 parse var d1 d2 '<br>' d1 dt=dt||d2||'0a'x end d1=dt||d1 dt='' do while d1~='' parse var d1 d2 '<' . '>' d3 '<' . '>' d4 '<' . '>' d5 '<' . '>' d6 '<' . '>' d7 '<' . '>' d12 '<' . '>' d13 '<' . '>' d14 '<' . '>' d15 '<' . '>' d16 '<' . '>' d17 '<' . '>' d22 '<' . '>' d23 '<' . '>' d24 '<' . '>' d25 '<' . '>' d26 '<' . '>' d27 '<' . '>' d32 '<' . '>' d33 '<' . '>' d34 '<' . '>' d35 '<' . '>' d36 '<' . '>' d37 '<' . '>' d1 dt=dt||d2||d3||d4||d5||d6||d7||d12||d13||d14||d15||d16||d17||d22||d23||d24||d25||d26||d27||d32||d33||d34||d35||d36||d37 end call open(fh,'awnpipe:dec/u/f','W') call writech(fh,dt) call close(fh) call open(fh,'awnpipe:dec','R') sel=readch(fh,64000) call close(fh) return(sel)